package com.itheima.health.service.impl;

import com.itheima.health.dao.MemberDao;
import com.itheima.health.pojo.Member;
import com.itheima.health.service.MemberService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 会员SERVICE实现类
 */
@Service
@Slf4j
public class MemberServiceImpl implements MemberService {
    @Autowired
    private MemberDao memberDao;

    /**
     * 根据手机号查询会员信息
     * @param telephone
     * @return
     */
    @Override
    public Member getMemberByPhoneNumber(String telephone) {
        Member member= memberDao.selectOneByPhoneNumber(telephone);
        return member;
    }

    /**
     * 新增会员
     * @param member
     */
    @Override
    public void save(Member member) {
        memberDao.insert(member);
    }

    @Override
    public Member getMemberById(Integer memberId) {
        Member member =memberDao.selectOneById(memberId);
        return member;
    }

    /**
     * 查看今日新增会员数
     * @param regTime
     * @return
     */
    @Override
    public Integer getCountByRegTime(String regTime) {
        return memberDao.selectCount(regTime);
    }

    /**
     * 查看总会员数
     * @return
     */
    @Override
    public Integer getCount() {

        return  memberDao.selectCount(null);
    }

    @Override
    public Integer getMonthCount(String month) {
        return  memberDao.selectCount2(month);
    }

    /**
     * 获取一周会员数
     * @param week
     * @return
     */
    @Override
    public Integer getWeekCount(String week) {

        return  memberDao.selectCount2(week);
    }
}
